<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <!-- React核心库 -->
  <script src="../build/react.min.js"></script>
  <!-- React-DOM提供与DOM相关的功能  -->
  <script src="../build/react-dom.min.js"></script>
  <!-- Browser.js 的作用是将 JSX 语法转为 JavaScript 语法 -->
  <script src="../build/browser.min.js"></script>
</head>
<body>
<div id="example"></div>
<script type="text/babel">
  // this.props 表示那些一旦定义，就不再改变的特性，而 this.state 是会随着用户互动而产生变化的特性。
  var LinKButton = React.createClass({
    getInitialState: function () {
      return {
        flag1: false,
        flag2: false
      }
    },
    handleClick: function () {
      this.setState({
        flag1: !this.state.flag1,
        flag2: !this.state.flag2
      });
    },
    render: function () {
      var button2Text = this.state.flag1 ? 'Hello1' : 'Hello2';
      var button1Text = this.state.flag2 ? 'button1Text111' : 'button1Text222';
      return (
        <div>
          <h1>{button1Text}</h1>
          <input type="button" value={this.props.name}/>
          <br/>
          <input type="button" onClick={this.handleClick} value={button2Text}/>
        </div>
      )
    }
  });

  ReactDOM.render(<LinKButton name="button1"/>, document.getElementById("example"));
</script>
</body>
</html>